<?php
/***
* @version $Id: pagestart.php 336 2007-01-23 08:12:56Z flexiondotorg $
* @copyright (c) 2006 - 2007 Flexion.Org
*            (c) 2004 - 2005 Project Minerva
*            (c) 2001 - 2006 phpBB Group
* @license   http://opensource.org/licenses/gpl-license.php GNU Public License
***/

if (!defined('IN_R3BORN'))
{
	die('Hacking attempt');
}

define('IN_ADMIN', true);
include($root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

### R3-born - ADD (Jnr. Admin)
#
include_once($root_path . 'includes/functions_admin.' . $phpEx);
#
### R3-born - END ADD

if (!$userdata['session_logged_in'])
{
	redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx", true));
}
else
{
	//Make sure this user can access this URL requested.
	$testbase = basename(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
	$testmodule = get_var('module', '');
	$testfile = get_var('file', $testbase);

	if ( !jr_admin_secure($testfile, $testmodule) )
	{
	    message_die(GENERAL_ERROR, $lang['Error_Module_ID'], '', __LINE__, __FILE__);
	}
	else
	{
		unset ($testbase);
		unset ($testmodule);
		unset ($testfile);
	}
}

if ($_GET['sid'] != $userdata['session_id'])
{
	redirect("index.$phpEx?sid=" . $userdata['session_id']);
}

if (!$userdata['session_admin'])
{
	redirect(append_sid("login.$phpEx?redirect=admin/index.$phpEx&admin=1", true));
}

if (empty($no_page_header))
{
	// Not including the pageheader can be neccesarry if META tags are
	// needed in the calling script.
	page_header_admin();
}

?>